package com.dhcc.core.modules.system.warpper;

import java.util.Map;

import com.dhcc.core.framework.base.warpper.BaseControllerWarpper;
import com.dhcc.core.framework.util.CommonUtil;
import com.dhcc.core.modules.system.cache.dept.DeptCache;
import com.dhcc.core.modules.system.cache.user.UserCache;

/**
 * 部门列表的包装
 * 
 * @ClassName: DeptWarpper
 * @Description: TODO
 * @author: cyf
 * @date: 2018年1月2日 上午10:43:13
 */
public class DeptWarpper extends BaseControllerWarpper {

    public DeptWarpper(Object list) {
        super(list);
    }

    @Override
    public void warpTheMap(Map<String, Object> map) {

        Long pid = (Long) map.get("parentId");
        Long leader = (Long) map.get("leader");
        Long superior = (Long) map.get("superior");

        if (CommonUtil.isEmpty(pid) || pid.equals(0L)) {
            map.put("parentName", "");
        } else {
            map.put("parentName", DeptCache.me().getDeptNameById(pid));
        }
        if (CommonUtil.isEmpty(leader)) {
            map.put("leaderName", "");
        } else {
            map.put("leaderName", UserCache.me().getUserNameById(leader));
        }
        if (CommonUtil.isEmpty(superior)) {
            map.put("superiorName", "");
        } else {
            map.put("superiorName", UserCache.me().getUserNameById(superior));
        }
    }

}
